import processors
from moviepy.editor import *


def subclip(inputPath, outPath, start_time, end_time):
    print("you are shine")


def printHello():
    printHello("hello world")


if __name__ == '__main__':
    # processors.reverse_video(r'E:\songhq\video\login.mp4',r'E:\songhq\video\aa.mp4')
    # clip = VideoFileClip(r'E:\songhq\video\login.mp4').rotate(180)
    # clip.write_videofile(r'E:\songhq\video\login_180.mp4')
    # font = TextClip.list('font')
    # for a in font:
    #     print("字体" + a)

    inputPath = r'E:\songhq\video\login.mp4'
    inputPath2 = r'E:\songhq\video\video.mp4'

    outPath = r'E:\songhq\video\login_hebing.mp4'
    musicPath = r'E:\songhq\video\追光者.mp3'
    start_time = 0
    end_time = 7
    video = VideoFileClip(inputPath)
    video2 = VideoFileClip(inputPath2)

    # 对视频进行剪辑
    clipped_video = video.subclip(start_time, end_time)
    video2 = video2.subclip(0, 3)
    final_clip = concatenate_videoclips([clipped_video, video2])
    # 添加文字
    # txtclip = TextClip(inf, font='仿宋_GB2312.ttf', fontsize=18, color='blue', bg_color='white', transparent=True).set_duration(30).resize((clip.size[0], clip.size[1] * 2)).set_fps(clip.fps)

    text = TextClip("MyHolidays", fontsize=90, color='white', font='simfang.ttf')

    # 插入图片
    text = text.set_position('center').set_duration(5)
    # 添加音乐 .subclip(0, 7) 可以截片段
    audio = AudioFileClip(musicPath).subclip(40, 50)
    # 将文字和音乐添加到视频中
    final_video = CompositeVideoClip([final_clip, text])
    final_video = final_video.set_audio(audio)
    final_video.write_videofile(outPath)
